
#include <iostream>
#include <string.h>
#include <cstdlib>

using namespace std;

class Student /*类一般用大写*/
{
public:
    Student(string n)
        :name(n) //构造函数对私有成员的初始化
    {
        if(head == NULL)
        {
            head = this;
            this->next = NULL;
        }
        else
        {
            this->next = head;
            head = this;
        }
    }
    static void printStudentList();
    static void deletStudentList();
private:
    string name;
    Student *next;
    static Student *head;
};

void Student::printStudentList()
{
    Student *p = head;
    while(p != NULL)
    {
        cout<<p->name<<endl;
        p = p->next;
    }
}

void Student::deletStudentList()
{
    Student *p = head;
    
    while(head)
    {
        head = head->next;
        delete p;
        p = head;
    }
}

Student *Student::head = NULL;

int main(void)
{
    string name;
    string postNmae;
    char buff[1024];
    for(int i=0; i<10; ++i)
    {
        name = "stu";
        //postNmae = (itoa(i,buff, 10 ));//没有itoa
        
        //name += postNmae;
        new Student(name);
    }
    Student::printStudentList();
    Student::deletStudentList();

    return 0;
}

